/*
 *  Copyright 2011-2012 Redia A/S
 * 
 *  This file is part of Redias Android Utilities.
 *
 *  Redias Android Utilities is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Redias Android Utilities is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Redias Android Utilities.  If not, see <http://www.gnu.org/licenses/>.
 */
package dk.redia.lib.model;

import java.util.Date;
import java.util.Map;

import dk.redia.lib.log.Log;

public class Gallery {
	
	private static final String logTag = "Gallery";
	private String id;
	private Date created;
	private String description;
	private String name;
	private Date lastUpdated;
	private String ownerUserId;
	
	public static Gallery fromMap(Map<String, Object> map) {
		if (!map.containsKey("id")) {
			Log.e(logTag, "Missing id field in gallery");
			return null;
		}
		if (!map.containsKey("created")) {
			Log.e(logTag, "Missing created field in gallery");
			return null;
		}
		if (!map.containsKey("description")) {
			Log.e(logTag, "Missing description field in gallery");
			return null;
		}
		if (!map.containsKey("name")) {
			Log.e(logTag, "Missing name field in gallery");
			return null;
		}
		if (!map.containsKey("lastUpdated")) {
			Log.e(logTag, "Missing lastUpdated field in gallery");
			return null;
		}
		if (!map.containsKey("ownerUserId")) {
			Log.e(logTag, "Missing ownerUserId field in gallery");
			return null;
		}
		
		Gallery g = new Gallery();
		g.setId((String)map.get("id"));
		g.setCreated((Date)map.get("created"));
		g.setDescription((String)map.get("description"));
		g.setName((String)map.get("name"));
		g.setLastUpdated((Date)map.get("lastUpdated"));
		g.setOwnerUserId((String)map.get("ownerUserId"));
		
		return g;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getLastUpdated() {
		return lastUpdated;
	}

	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}

	public String getOwnerUserId() {
		return ownerUserId;
	}

	public void setOwnerUserId(String ownerUserId) {
		this.ownerUserId = ownerUserId;
	}
	
}
